#define _CRT_SECURE_NO_WARNINGS 1

#include <string>
#include <vector>
using namespace std;

class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        string tmp = strs[0];
        for (int max = 0; max < tmp.size(); ++max)
        {
            for (auto& e : strs)
            {
                if (e[max] != tmp[max])
                    return tmp.substr(0, max);
            }
        }
        return tmp;
    }
};